import threading
import time
from threading import Thread
from threading import Thread,Lock
lock_obj=Lock()
ticket=50
def sale_ticket():
    global ticket
    for i in range (100):
        lock_obj.acquire()
        if ticket>0:
            print(f'{threading.current_thread().name}正在销售{ticket}张票')
            ticket-=1
        time.sleep(1)

        lock_obj.release()


if __name__ == '__main__':
    for i in range (3):
        t=Thread(target=sale_ticket())